#pragma once
#include <iostream>
#include <string>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
class InetAddr // 网络地址与本地地址的转化
{
public:
    InetAddr(struct sockaddr_in &addr)
        : _addr(addr)
    {
        _port = ntohs(addr.sin_port);
        _ip = inet_ntoa(addr.sin_addr);
    }
    uint16_t Port() { return _port; }
    std::string Ip() { return _ip; }
    ~InetAddr()
    {
    }

private:
    struct sockaddr_in _addr;
    uint16_t _port;
    std::string _ip;
};